using UnityEngine;

public class ArrowManager : MonoBehaviour
{
	public static ArrowManager Instance;

	public GameObject go_Arrow;

	private float timer;

	private Vector3 posStart;

	private int count;

	private GameObject[] arrows;

	private void Start()
	{
		Instance = this;
		posStart = base.transform.position;
		count = 0;
		arrows = new GameObject[100];
	}

	private void Update()
	{
		if (count < 100 && BadLogic.playing)
		{
			timer += Time.deltaTime;
			if (timer >= 0.25f)
			{
				timer = 0f;
				ShotArrow();
			}
		}
	}

	private void ShotArrow()
	{
		int num = UnityEngine.Random.Range(-50, 30);
		GameObject gameObject = UnityEngine.Object.Instantiate(go_Arrow);
		gameObject.transform.position = new Vector3(posStart.x, num, 0f);
		arrows[count] = gameObject;
		count++;
	}

	public void RessetArrow()
	{
		GameObject[] array = arrows;
		foreach (GameObject gameObject in array)
		{
			if (gameObject != null)
			{
				UnityEngine.Object.Destroy(gameObject);
			}
		}
		count = 0;
		timer = 0f;
	}
}
